#ifndef WEBVIEW_H
#define WEBVIEW_H

#include <QWidget>
#include <QWebView>
#include "bookmarkitem.h"
#include <QDebug>
#include <QResizeEvent>
#include "tabitem.h"

class WebView : public QWidget
{
	Q_OBJECT
public:
	explicit WebView(QWidget *parent = 0);
signals:
	void urlChanged(QString url, int index);
	void iconChanged(QIcon icon, int index);
	void titleChanged(QString title, int index);
public slots:
	void loadUrl(QString url);
	void showPage(TabItem *tab);

private slots:
	void emit_urlChanged(QUrl url) { emit urlChanged(url.toString(), currentTab->tabId()); }
	void emit_iconChanged(void) { emit iconChanged(m_webView->icon(), currentTab->tabId()); }
	void emit_titleChanged(QString title) { emit titleChanged(title, currentTab->tabId()); }
protected:
	virtual void resizeEvent(QResizeEvent *event);
private:
	TabItem *currentTab;
	QWebView *m_webView;
};

#endif // WEBVIEW_H
